package com.kk.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;
import java.util.Set;

/**
 * @author: kevin
 * @data: 2018-08-20 21:35
 * @desc:
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
public class Menu extends BaseEntity {

    @ManyToOne
    @JsonIgnore
    private Menu parent;

    @Column(nullable = false)
    @NonNull
    private String name;

    private int level;
    //同级排序
    @Column(nullable = true)
    private int sort;
    //菜单等级描述
    private String levelDesc;

    @Transient  //不在数据库生成字段
    private Set<Menu> children;

    //菜单类型,默认为菜单
    private int menuType = 1;

    //页面相对路径
    private String url;

    //icon
    private String icon;


    public Menu() {

    }

    public Menu(String name, int level, String url) {
        this.name = name;
        this.level = level;
        this.url = url;
    }
}
